home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
query2.fr_
/
query2.fr
Wrap
Text File
|
1995-07-05
|
8KB
|
290 lines
VERSION 4.00
Begin VB.Form frmMain
BackColor = &H00C0C0C0&
Caption = "Publisher Parameter"
ClientHeight = 2790
ClientLeft = 1080
ClientTop = 1515
ClientWidth = 6720
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3195
Left = 1020
LinkTopic = "Form1"
ScaleHeight = 2790
ScaleWidth = 6720
Top = 1170
Width = 6840
Begin VB.CommandButton cmdPublisher
Caption = "&Publisher"
Height = 435
Left = 3720
TabIndex = 15
Top = 1980
Width = 1095
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Height = 435
Left = 5160
TabIndex = 14
Top = 1980
Width = 1155
End
Begin VB.CommandButton cmdMove
Caption = ">|"
Height = 435
Index = 3
Left = 2640
TabIndex = 13
Top = 1980
Width = 495
End
Begin VB.CommandButton cmdMove
Caption = ">"
Default = -1 'True
Height = 435
Index = 2
Left = 2160
TabIndex = 12
Top = 1980
Width = 495
End
Begin VB.CommandButton cmdMove
Caption = "<"
Height = 435
Index = 1
Left = 1680
TabIndex = 11
Top = 1980
Width = 495
End
Begin VB.CommandButton cmdMove
Caption = "|<"
Height = 435
Index = 0
Left = 1200
TabIndex = 10
Top = 1980
Width = 495
End
Begin VB.TextBox txtPublisher
Height = 315
Left = 2640
TabIndex = 9
Top = 1380
Width = 3855
End
Begin VB.TextBox txtYearPublished
Height = 315
Left = 1320
TabIndex = 8
Top = 1380
Width = 735
End
Begin VB.TextBox txtISBN
Height = 315
Left = 1320
TabIndex = 5
Top = 960
Width = 2295
End
Begin VB.TextBox txtTitle
Height = 315
Left = 1320
TabIndex = 3
Top = 540
Width = 5175
End
Begin VB.TextBox txtAuthor
Height = 315
Left = 1320
TabIndex = 1
Top = 120
Width = 2595
End
Begin VB.Label Label5
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "by:"
Height = 195
Left = 2220
TabIndex = 7
Top = 1440
Width = 270
End
Begin VB.Label Label4
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Published:"
Height = 195
Left = 300
TabIndex = 6
Top = 1440
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "ISBN:"
Height = 195
Left = 300
TabIndex = 4
Top = 1020
Width = 510
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Title:"
Height = 195
Left = 300
TabIndex = 2
Top = 600
Width = 450
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Author:"
Height = 195
Left = 300
TabIndex = 0
Top = 180
Width = 630
End
End
Attribute VB_Name = "frmMain"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private rs As Recordset
Public SelectedPubID As Integer
Private Sub Form_Load()
cmdPublisher_Click
End Sub
Private Sub cmdPublisher_Click()
' Show frmSelectPublisher to get a selection from the user.
frmSelectPublisher.Show 1
If SelectedPubID > 0 Then
' The user selected a publisher, so run the query.
RunQuery
Else
' The user did not select a publisher, so clear the form and
' disable the browse buttons.
frmMain.Caption = "No Titles"
EnableBrowse False
ClearForm
End If
End Sub
Sub DisplayRecord()
If Not IsNull(rs![Author]) Then txtAuthor = rs![Author] Else txtAuthor = ""
If Not IsNull(rs![Title]) Then txtTitle = rs![Title] Else txtTitle = ""
If Not IsNull(rs![ISBN]) Then txtISBN = rs![ISBN] Else txtISBN = ""
If Not IsNull(rs![Year Published]) Then txtYearPublished = rs![Year Published] Else txtYearPublished = ""
If Not IsNull(rs![Company Name]) Then txtPublisher = rs![Company Name] Else txtPublisher = ""
End Sub
Private Sub cmdMove_Click(Index As Integer)
Const MOVE_FIRST = 0
Const MOVE_PREVIOUS = 1
Const MOVE_NEXT = 2
Const MOVE_LAST = 3
Select Case Index
Case MOVE_FIRST
rs.MoveFirst
Case MOVE_LAST
rs.MoveLast
Case MOVE_PREVIOUS
rs.MovePrevious
If rs.BOF Then rs.MoveFirst
Case MOVE_NEXT
rs.MoveNext
If rs.EOF Then rs.MoveLast
End Select
DisplayRecord
End Sub
Sub ClearForm()
' Clear all the text boxes.
txtAuthor = ""
txtTitle = ""
txtISBN = ""
txtYearPublished = ""
txtPublisher = ""
End Sub
Sub RunQuery()
Dim db As DATABASE
Dim dbName As String
Dim qd As QueryDef
On Error GoTo QueryError
' Get the database name and open the database.
dbName = BiblioPath() ' BiblioPath is a function in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Open the query definition
Set qd = db.QueryDefs("Publisher's Titles By Author")
' Set the value of the query definition's Parameter object to
' the PubID of the publisher selected by the user.
qd.PARAMETERS![Publisher] = SelectedPubID
' Open a recordset based on the query.
Set rs = qd.OpenRecordset()
If rs.RecordCount > 0 Then
' There's at least one record in the recordset, so update the
' form and display the first record.
frmMain.Caption = Str$(rs.RecordCount) & _
IIf(rs.RecordCount = 1, " Title", " Titles")
EnableBrowse True
DisplayRecord
Else
' There are no titles in the recordset, so clear the form.
frmMain.Caption = "No Titles"
EnableBrowse False
ClearForm
End If
Exit Sub
QueryError:
MsgBox Error$, vbExclamation
Exit Sub
End Sub
Sub EnableBrowse(enable As Boolean)
Dim i As Integer
' Enable or disable the browse buttons, based on the value of the
' argument.
For i = 0 To 3
cmdMove(i).Enabled = enable
Next i
End Sub
Private Sub cmdClose_Click()
End
End Sub